public class Tools {
    private static String lineToHump(String target) {
        if (target == null || target.isEmpty()) {
            return target;
        }

        StringBuilder result = new StringBuilder();
        boolean capitalizeNext = false;

        for (int i = 0; i < target.length(); i++) {
            char ch = target.charAt(i);
            if (ch == '-') {
                capitalizeNext = true;
            } else if (capitalizeNext) {
                result.append(Character.toUpperCase(ch));
                capitalizeNext = false;
            } else {
                result.append(ch);
            }
        }

        // 处理首位字符如果是下划线的情况
        if (result.length() > 0 && result.charAt(0) == '-') {
            result.deleteCharAt(0);
            if (result.length() > 0) {
                result.setCharAt(0, Character.toUpperCase(result.charAt(0)));
            }
        }

        return result.toString();
    }

    public static void main(String[] args) {
        System.out.println(lineToHump("reverse-nodes-in-k-group"));
    }
}

